package wol;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.KeyStroke;

public class GUI extends JFrame implements ActionListener, ItemListener {
	public GUI() {
		super("Title");
		addMenu(this);
		setSize(300, 300);
		setLocation(300, 300);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        JPanel j = new JPanel();
        this.add(j);
	}
	
	private void addMenu(JFrame f) {
		JMenuBar menuBar = new JMenuBar();
		
		JMenu menu = new JMenu("A Menu");
		menu.setMnemonic(KeyEvent.VK_A);
		menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
		
		JMenuItem item = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
		item.setAccelerator(KeyStroke.getKeyStroke(
		        KeyEvent.VK_1, ActionEvent.ALT_MASK));
		item.getAccessibleContext().setAccessibleDescription(
		        "This doesn't really do anything");
		item.addActionListener(this);
		menu.add(item);
		
		menuBar.add(menu);
		f.setJMenuBar(menuBar);
	}
	
	
	public static void main(String[] args) {
		GUI g = new GUI();
	}

	@Override
	public void itemStateChanged(ItemEvent arg0) {
		
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		System.out.println(arg0.getActionCommand());
		System.out.println(arg0.getID());
		System.out.println(arg0);
		// TODO Auto-generated method stub
		
	}
}
